package com.demo.chapter5stream2;

import java.util.Arrays;
import java.util.stream.IntStream;

import com.demo.domain.Dish;

public class Reduce {

	public static void demo(){
		IntStream munbers = Arrays.stream(new int[]{100, 92, 3420, 43, 439});
		System.out.println(munbers.reduce(Integer::min));
		IntStream munbers2 = Arrays.stream(new int[]{100, 92, 3420, 43, 439});
		System.out.println(munbers2.reduce(Integer::max));
	}

	//返回菜品总数
	public static void demo2(){
		System.out.println(Dish.menu.stream().map(d -> 1).reduce(0, (a, b) -> a + b));
	}

	public static void main(String[] args) {
		demo();
		demo2();
	}

}
